package cn.tedu.properties.mapper;

import cn.tedu.properties.pojo.entity.Property;
import cn.tedu.properties.pojo.vo.PropertyVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface PropertiesMapper extends BaseMapper<Property>{

//    @Select("SELECT id,asset_name,asset_code,category_id,asset_category" +
//            ",employee_id,employee_name,brand,status,remark,add_time FROM ems.property")
//    List<PropertyVO> selectVOList(@Param(Constants.WRAPPER) QueryWrapper<Property> queryWrapper);


//    @Override
//    @Select("SELECT id,asset_name,asset_code,category_id,asset_category" +
//            ",employee_id,employee_name,brand,status,remark,add_time FROM ems.property")
//    List<Property> selectList(@Param("ew") Wrapper<Property> queryWrapper);


    /*如果想临时不分页，可以在初始化 IPage 时 size 参数传入小于 0 的值。
        如果返回类型是 List，则入参的 IPage 可以为 null，但需要手动设置入参的 IPage.setRecords(返回的 List)。*/
    /*@Select("SELECT id,asset_name,asset_code,category_id,asset_category" +
            ",employee_id,employee_name,brand,status,remark,add_time FROM ems.property")
    Page<PropertyVO> selectPage(Page<PropertyVO> page,@Param(Constants.WRAPPER) Wrapper<Property> queryWrapper);*/
    @Select("SELECT id,asset_name,asset_code,category_id,asset_category" +
            ",employee_id,employee_name,brand,status,remark,add_time FROM ems.property ${ew.customSqlSegment}")
    Page<PropertyVO> selectPage(Page<PropertyVO> page,@Param(Constants.WRAPPER) Wrapper<Property> queryWrapper);

    int saveBunch(ArrayList<Property> list);

    int scrapByIds(@Param("property")Property property,@Param("array")Long[] array);
}
